/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.alxbrendmaquinarias.model;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author Max
 */
@Entity
@Table(name = "detail_sale_product", catalog = "sgcom", schema = "")
@NamedQueries({
    @NamedQuery(name = "DetailSaleProduct.findAll", query = "SELECT d FROM DetailSaleProduct d"),
    @NamedQuery(name = "DetailSaleProduct.findById", query = "SELECT d FROM DetailSaleProduct d WHERE d.id = :id"),
    @NamedQuery(name = "DetailSaleProduct.findByAmount", query = "SELECT d FROM DetailSaleProduct d WHERE d.amount = :amount"),
    @NamedQuery(name = "DetailSaleProduct.findByPriceUnit", query = "SELECT d FROM DetailSaleProduct d WHERE d.priceUnit = :priceUnit")})
public class DetailSaleProduct implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Integer id;
    @Column(name = "amount")
    private Integer amount;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "price_unit")
    private Double priceUnit;
    @JoinColumn(name = "sale_product_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private SaleProduct saleProductId;
    @JoinColumn(name = "product_id", referencedColumnName = "id")
    @ManyToOne
    private Product productId;

    public DetailSaleProduct() {
    }

    public DetailSaleProduct(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getAmount() {
        return amount;
    }

    public void setAmount(Integer amount) {
        this.amount = amount;
    }

    public Double getPriceUnit() {
        return priceUnit;
    }

    public void setPriceUnit(Double priceUnit) {
        this.priceUnit = priceUnit;
    }

    public SaleProduct getSaleProductId() {
        return saleProductId;
    }

    public void setSaleProductId(SaleProduct saleProductId) {
        this.saleProductId = saleProductId;
    }

    public Product getProductId() {
        return productId;
    }

    public void setProductId(Product productId) {
        this.productId = productId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DetailSaleProduct)) {
            return false;
        }
        DetailSaleProduct other = (DetailSaleProduct) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.alxbrendmaquinarias.model.DetailSaleProduct[ id=" + id + " ]";
    }
    
}
